package com.jdyfy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jdyfy.dto.HistoTaskDTO;
import com.jdyfy.entity.Project;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface ProjectMapper extends BaseMapper<Project> {

    /**
     * 批量删除项目
     */
     int delByIds(@Param("ids") List<Long> ids);

    /**
     * 分页获取项目数据
     * pageNum: 第几页，pageSize：每页展示条数
     * @return
     */
    @Select("SELECT * FROM project WHERE project_number like concat('%', #{projectNumber} ,'%') LIMIT #{pageNum} , #{pageSize}")
    List<Project> getProjectPage(@Param("pageNum") Integer pageNum,
                                 @Param("pageSize") Integer pageSize,
                                 @Param("projectNumber") String projectNumber);

    /**
     * 修改项目
     */
    Integer updateProject(Project project);

    /**
     * 批量修改项目状态
     */
    Integer updateAnnoStatusByProjectNames(List<String> projectNames, Integer annoStatus);

    /**
     * 获取项目状态在annoStatusStart和annoStatusEnd之间的数据
     * @param
     * @return
     */
    @Select("SELECT * FROM project WHERE anno_status >= #{annoStatusStart} and anno_status <= #{annoStatusEnd}")
    List<Project> getProjectsByStatus(@Param("annoStatusStart") Integer annoStatusStart,@Param("annoStatusEnd") Integer annoStatusEnd);

    @Select("select * from project where project_number = #{projectNumber}")
    Project selectByNumber(String projectNumber);

    @Delete("delete from project where project_number = #{expiredProjectName}")
    void deleteByName(String expiredProjectName);

    // 通过成交人查询中标项目
    List<Project> getWinnotiProjectByDealer(String departmentName);

    List<HistoTaskDTO> getHistoProject(int status);
}
